Skip to content

nixos/home: fold script-installed laptop units into the flake (code#3720) - #3722

Merged
dezren39 merged 2 commits into
mainfrom
infra/flake-fold-units
Nov 1, 2026
Merged

dezren39 merged 2 commits into
mainfrom
infra/flake-fold-units

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Refs #3720. Drew ordered 2026-11-01 ("fix all now").

What

One home-manager module per script-installed laptop system, enabled from nixos/hosts/default.nix next to the existing laptop modules:

Module Units
nixos/home/github-backup.nix github-backup-drain/-fetch/-reconcile (.service + .timer)
nixos/home/worktree-reaper.nix worktree-reaper (.service + .timer)
nixos/home/cloudflare-quota-export.nix cloudflare-quota-export (.service + .timer)
nixos/home/meta-quota-export.nix meta-quota-export (.service + .timer)
nixos/home/dashboard-backup.nix dashboard-backup (.service + .timer)
nixos/home/oc-password-sync.nix oc-password-sync (.service)

Semantics replicate the installed plain-file units exactly (ExecStart, WorkingDirectory, timer schedules, Persistent/RandomizedDelaySec, TimeoutStartSec, Nice, enablement). Executed scripts stay at their checkout paths per the fleet-feed-collector precedent — only unit provenance changes. The github-backup drainer's Bitwarden access stays inside its wrapper script; the units carry no environment of their own, as today.

Intentional difference (one)

worktree-reaper's ExecStart moves from the pre-merge bootstrap worktree ~/git/code-wt-reaper/infra/worktree-reaper/... to the canonical primary path ~/git/code/infra/worktree-reaper/..., retiring the bootstrap install per the reaper README (absorbs the #3698 post-merge tail). This PR therefore lands after #3698 merges — before that, the primary path does not exist.

Equivalence + activation

  • The amd configuration is built from this branch on the laptop and the generated units are diffed field-by-field against the installed files (results in a follow-up comment).
  • Activation: the plain unit files are first moved to ~/.local/state/flake-fold-backup-2026-11-01/ on the laptop (rollback = restore them), then the established ~/run-switch.sh path runs; each migrated unit is verified to resolve into /nix/store with its timer armed, plus one functional run per system.

Not in scope: rustdesk.service (vendor), git-maintenance@ (git's own), oc-sumauto (transient, no file).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…720)

One home-manager module per system, enabled from nixos/hosts/default.nix next to the existing laptop modules, replicating the installed units' semantics exactly (ExecStart, WorkingDirectory, timer schedules, timeouts, Nice); executed scripts stay at their checkout paths per the fleet-feed-collector precedent — only unit provenance changes.

Systems: github-backup (drain/fetch/reconcile), worktree-reaper, cloudflare-quota-export, meta-quota-export, dashboard-backup, oc-password-sync.

One intentional difference: worktree-reaper's ExecStart moves from the pre-merge bootstrap worktree (~/git/code-wt-reaper) to the canonical primary path (~/git/code/infra/worktree-reaper), retiring the bootstrap install per the reaper README; this therefore lands after #3698 merges.
@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 14:09
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 29 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4a3f09cd-60c5-4f14-9951-f514ed3f994f
Commits

Reviewing files that changed from the base of the PR and between c193d62 and 82a273f.

Files selected for processing: 7
  • nixos/home/cloudflare-quota-export.nix
  • nixos/home/dashboard-backup.nix
  • nixos/home/github-backup.nix
  • nixos/home/meta-quota-export.nix
  • nixos/home/oc-password-sync.nix
  • nixos/home/worktree-reaper.nix
  • nixos/hosts/default.nix
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T14:24:55.787951Z 82a273f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78b4fc0ca5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

};
Service = {
Type = "oneshot";
ExecStart = "/usr/bin/env python3 ${home}/git/code/infra/worktree-reaper/bin/worktree_reaper.py";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Merge the reaper implementation before switching its path

On a primary checkout of this commit, the newly enabled service invokes a script that does not exist: the target commit's recursive Git tree and repository-wide searches contain no infra/worktree-reaper implementation or generator supplying it. Consequently, each hourly run exits with Python's file-not-found error instead of retiring worktrees. The commit message acknowledges the dependency on #3698, but that prerequisite is not present in the reviewed tree; merge it before landing this change, or retain the bootstrap execution path until then.

Useful? React with 👍 / 👎.

@dezren39

dezren39 commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

Equivalence check (pre-activation)

The amd configuration was evaluated on the laptop from this branch, and the resulting systemd.user.services / systemd.user.timers definitions — the exact data home-manager's generator serializes into the flake unit files — were diffed field-by-field against the 15 installed plain files (parsed per-section, list-valued keys compared as token sets; home-manager's empty bookkeeping defaults, which serialize to nothing, normalized away):

  • 14/15 units IDENTICAL in every field — Description, After/Wants, ExecStart, WorkingDirectory, Type, TimeoutStartSec, Nice, OnCalendar/OnBootSec/OnUnitActiveSec, Persistent, RandomizedDelaySec, Timer.Unit, Install.WantedBy all match.
  • worktree-reaper.service: identical except the one intentional difference — ExecStart ~/git/code-wt-reaper/infra/worktree-reaper/bin/worktree_reaper.py → ~/git/code/infra/worktree-reaper/bin/worktree_reaper.py.

Also verified: nixfmt --check clean on all 7 touched files; the reaper's first scheduled fire from the installed unit happened on time during this work (08:04:42 CST, 31 trees reaped, 0 errors) — the migration prep did not disturb it.

A full toplevel nix build from this branch is running on the laptop for the file-level confirmation of the same diff; results will be added here when it lands.

Activation state

Staged, not switched. The switch requires Drew's interactive sudo password (sudo -n verified failing on the laptop), so the plain unit files are untouched. Prepared on the laptop: ~/.local/state/flake-fold-backup-2026-11-01/ with a README containing the exact move + ~/run-switch.sh + verify + rollback commands. Merge order: #3698 first, then this PR.

Live census correction: the oc-password-sync system is two units, not one. oc-password-sync.path (also a plain file) watches the prod OpenCode service file and triggers the service; it is the unit actually enabled into default.target. The .service's own [Install] is dormant. Both are now declared in nixos/home/oc-password-sync.nix, replicating the installed files exactly.
@dezren39

dezren39 commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

Scope correction + final state

16 unit files, not 15. Live verification found a unit the original census missed: oc-password-sync.path (also a plain file) — the path unit that watches the prod OpenCode service file and triggers oc-password-sync.service; it is what is actually enabled into default.target (the service's own [Install] is dormant). Commit 82a273f7 folds it in via systemd.user.paths; its evaluated definition matches the installed file field-for-field, same as the rest. Updated totals: 15/16 units identical in every field, the 16th being worktree-reaper.service with only the intentional ExecStart move.

Found while verifying (pre-existing, not a fold regression): oc-password-sync.service currently FAILS on every trigger — its script dies on a missing openchamber.service.d/external-opencode.conf drop-in. Filed separately as #3724.

Build note: repeated full-toplevel nix build attempts from this branch were made on the laptop; the surviving detached attempt is still running at the time of this comment (the box is under heavy fleet load; log ~/tmp-flake-fold/build3.log on the laptop). The equivalence result above rests on the completed evaluation of the exact amd config (exit 0) — the same evaluated values home-manager's generator serializes, and the same machinery behind the ~100 flake units already live on the machine. The file-level diff will be confirmed from the build output when it lands, and the staged runbook's post-switch checks cover the same ground at activation.

Activation remains staged on Drew's interactive sudo (move + ~/run-switch.sh runbook in ~/.local/state/flake-fold-backup-2026-11-01/ on the laptop). Merge order unchanged: #3698 first, then this PR.

@dezren39

dezren39 commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

File-level equivalence — confirmed for the built tree

The full toplevel nix build from this branch (commit 78b4fc0c) has now completed on the laptop (exit 0). The generated unit files were extracted from the built home-manager generation (home-manager-files/.config/systemd/user/) and diffed field-by-field against the installed plain files with the same parser as the evaluation check:

  • 14/15 files IDENTICAL in every field (byte-level field comparison, not just evaluation values).
  • worktree-reaper.service: only the intentional ExecStart path difference, as designed.

The 16th unit, oc-password-sync.path, was added in 82a273f7 after that build started; its evaluated definition already matches the installed file field-for-field, and the serializer's fidelity is now empirically settled by the 15 files above. A confirmation build of the branch tip is running (log ~/tmp-flake-fold/build4.log on the laptop) for completeness; activation remains staged on Drew's switch exactly as described in the earlier comment.

@dezren39

dezren39 commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

Equivalence closed: 16/16 at file level

The confirmation build of the branch tip (82a273f7) has also completed on the laptop (exit 0). Its generated oc-password-sync.path was extracted from the built home-manager generation and diffed against the installed file: IDENTICAL in every field.

Final tally for the whole fold, all at generated-file level: 15/16 units identical in every field; worktree-reaper.service differs only in the intentional ExecStart move (bootstrap worktree → primary checkout). Nothing about the activation state changes: still staged on the move + ~/run-switch.sh step, merge order #3698 → #3722.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant